package com.dong.mybatis.mapper;

import com.dong.mybatis.entity.Zone1;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author dong
 * @since 2025-07-24
 */
@Mapper
public interface Zone1Mapper extends BaseMapper<Zone1> {
    @Select("SELECT * FROM zone1 ORDER BY time DESC LIMIT 1")
    Zone1 selectLatest();
    @Select("SELECT * FROM zone1 WHERE time >= NOW() - INTERVAL 5 MINUTE ORDER BY time DESC")
    List<Zone1> selectLast5Minutes();
//    @Select("SELECT * FROM zone1 WHERE time BETWEEN #{start} AND #{end} ORDER BY time DESC")
//    List<Zone1> selectByTimeRange(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);
    @Select("SELECT * FROM zone1 WHERE time BETWEEN #{start} AND #{end} ORDER BY time ASC LIMIT 1")
    Zone1 selectByTimeRange(LocalDateTime start, LocalDateTime end);
//@Select("SELECT temp ,humi, a ,v ,l FROM zone1 ORDER BY time DESC LIMIT 1")
//Zone1 selectLatest();
//    @Select("SELECT * FROM zone1 WHERE time >= NOW() - INTERVAL 5 MINUTE ORDER BY time DESC")
//    List<Zone1> selectLast5Minutes();
//    //    @Select("SELECT * FROM zone1 WHERE time BETWEEN #{start} AND #{end} ORDER BY time DESC")
////    List<Zone1> selectByTimeRange(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);
//    @Select("SELECT * FROM zone1 WHERE time BETWEEN #{start} AND #{end} ORDER BY time ASC LIMIT 1")
//    Zone1 selectByTimeRange(LocalDateTime start, LocalDateTime end);

}
